package com.zzyl.nursing.service.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.zzyl.common.exception.base.BaseException;
import com.zzyl.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.LfdjMapper;
import com.zzyl.nursing.domain.Lfdj;
import com.zzyl.nursing.service.ILfdjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
/**
 * 来访登记Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-28
 */
@Service
public class LfdjServiceImpl extends ServiceImpl<LfdjMapper,Lfdj> implements ILfdjService
{
    @Autowired
    private LfdjMapper lfdjMapper;

    /**
     * 查询来访登记
     * 
     * @param id 来访登记主键
     * @return 来访登记
     */
    @Override
    public Lfdj selectLfdjById(Long id)
    {
        return getById(id);
    }

    /**
     * 查询来访登记列表
     * 
     * @param lfdj 来访登记
     * @return 来访登记
     */
    @Override
    public List<Lfdj> selectLfdjList(Lfdj lfdj)
    {
        return lfdjMapper.selectLfdjList(lfdj);
    }

    /**
     * 新增来访登记
     * 
     * @param lfdj 来访登记
     * @return 结果
     */
    @Override
    public int insertLfdj(Lfdj lfdj)
    {
        lfdj.setCreatrTime(LocalDateTime.now());
        Long id = lfdjMapper.selecti(lfdj);
        if(id != null){
            throw new BaseException("已存在此来访信息");
        }
        return lfdjMapper.insertLfdj(lfdj);
    }

    /**
     * 修改来访登记
     * 
     * @param lfdj 来访登记
     * @return 结果
     */
    @Override
    public int updateLfdj(Lfdj lfdj)
    {
        return updateById(lfdj)?1:0;
    }

    /**
     * 批量删除来访登记
     * 
     * @param ids 需要删除的来访登记主键
     * @return 结果
     */
    @Override
    public int deleteLfdjByIds(Long[] ids)
    {
        return removeByIds(Arrays.asList(ids))?1:0;
    }

    /**
     * 删除来访登记信息
     * 
     * @param id 来访登记主键
     * @return 结果
     */
    @Override
    public int deleteLfdjById(Long id)
    {
        return removeById(id)?1:0;
    }

}
